#include "Lemon_Web.h"
#include "Lemon_EPD.h"
#include "Ap_29demo.h"
#include <ESP8266WiFi.h>
#include <DNSServer.h>
/*************初始化***********************/

DNSServer dnsServer;
Lemon_Web Lemon;
Lemon_EPD Epd;

bool Reflash=false;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200); // 启动串口通讯
  // Lemon.Website_init();
  Lemon.Wifi_Message_Read();//从FS初始化WIFIConfig
  Lemon.Wifi_Connect(); //尝试连接WIFI
  Lemon.Website_init();
  // dnsServer.start(53, "*", IPAddress(192, 168, 4, 1));
  // 小米mm www.connect.rom.miui.com 华为 www.connectivitycheck.platform.hicloud.com
}

/**********************主程序循环**********************/
void loop() {
  // put your main code here, to run repeatedly:
  // dnsServer.processNextRequest();//处理DNS请求服务
  Lemon.Website_handle();
  if(Reflash==true)
  {
    Reflash=false;
    Epd.IO_settings();
    Epd.EPD_init(); // EPD init
    Epd.PIC_SPIFFS_display();
    Epd.EPD_refresh(); // EPD_refresh
    Epd.EPD_sleep(); // EPD_sleep,Sleep instruction is necessary, please do not delete!!!
    Lemon.handleLEDControl();
  }

}
